package com.example.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * Feign拦截器 可以用来做 授权，修改请求参数
 */
@Component
@Slf4j
public class CustomFeignInterceptor implements RequestInterceptor {

    public void apply(RequestTemplate requestTemplate) {
        log.info("custom feign interceptor...");
        requestTemplate.header("auth", "1234");
        //requestTemplate.query("id", "11111");   请求后添加参数  ?id=1111
        //requestTemplate.uri("/5");  把url里的的  @pathVarible的参数替换掉  /user/{id}/   -> /userId/5/
    }
}
